#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<iomanip>

using namespace std;

string discountPrices(string sentence, int discount) {
    double d = 1 - discount / 100.0;
    stringstream ss(sentence);
    string ans, w;
    while (ss >> w)
    {
        if (!ans.empty())
            ans += ' ';
        if (w.size() > 1 && w[0] == '$' && all_of(w.begin() + 1, w.end(), ::isdigit))
        {
            stringstream s;
            s << fixed << setprecision(2) << '$' << stoll(w.substr(1)) * d;
            ans += s.str();
        }
        else {
            ans += w;
        }
    }
    return ans;
}

int main()
{
    discountPrices("there are $1 $2 and 5$ candies in the shop", 50);
    return 0;
}